//
//  MainController.swift
//  WeiBo
//
//  Created by 江潘 on 15/6/24.
//  Copyright © 2015年 江潘. All rights reserved.
//

import UIKit


class MainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        addChildViewControllers()
        
        setValue(CustomTabBar(), forKey: "tabBar")
    }

    private func addChildViewControllers() {
        
        addChildViewController("tabbar_home", vc: HomeController(), title: "首页")
        addChildViewController("tabbar_message_center", vc: MessageController(), title: "消息")
        addChildViewController("tabbar_discover", vc: DiscoverController(), title: "发现")
        addChildViewController("tabbar_profile", vc: ProfileController(), title: "我")
    }
    
    private func addChildViewController(imgName:String,vc:UIViewController,title:String){
  
    // 注意：每个vc中都有tabBarItem（写代码设置tabBar的时候，需要在每个添加的控制器中设置tabBarItem属性）
        
         vc.title = title;
        
         vc.tabBarItem.image = UIImage(named: imgName)
        
         vc.tabBarItem.selectedImage = UIImage(named: imgName + "_highlighted")
        
         let nav = UINavigationController(rootViewController: vc)
        
         addChildViewController(nav)
    }
}
